package com.findme.fecedetection.ui

import android.support.v4.app.Fragment
import android.support.v4.content.ContextCompat
import android.view.View
import android.widget.ImageView
import android.widget.TextView
import com.findme.fecedetection.R
import com.findme.fecedetection.base.BottomTabActivity
import com.findme.fecedetection.ui.fragment.FindFragment
import com.findme.fecedetection.ui.fragment.HomeFragment
import com.findme.fecedetection.ui.fragment.MeFragment



class MainActivity : BottomTabActivity() {
    private val arrayOfFragment: Array<Fragment> = arrayOf(
            HomeFragment()//主页
            , FindFragment()//寻找
            , MeFragment()//我的
    )
    val mTabTitle = arrayOf("首页", "寻找领回",  "个人中心")
    val mTabRes = intArrayOf( R.mipmap.index_1, R.mipmap.heart_1, R.mipmap.user_1)
    val mTabResPressed = intArrayOf( R.mipmap.index, R.mipmap.heart, R.mipmap.user)

    override fun fragments(): Array<Fragment> = arrayOfFragment

    override fun setContentRes(): Int = R.layout.activity_main
    override fun initView() {
        super.initView()

    }

    override fun getTabViewResID(position: Int): Int = R.layout.layout_bottom_tab_view

    override fun changeTab(view: View, position: Int, isSelected: Boolean) {

        if (isSelected) {
            changeBar(position)
        }

        val tabIconRes: Int
        val color: Int
        if (isSelected) {
            tabIconRes = mTabResPressed[position]
            color = R.color.color_4864f3
        } else {
            tabIconRes = mTabRes[position]
            color = R.color.color_d8c7f2
        }
        val tabIcon: ImageView = view.findViewById(R.id.tab_content_image)
        tabIcon.setImageResource(tabIconRes)
        val tabText: TextView = view.findViewById(R.id.tab_content_text)
        tabText.text = mTabTitle[position]
        tabText.setTextColor(ContextCompat.getColor(this, color))
    }

    private fun changeBar(position: Int) {
        when (position) {

        }
    }







}
